package com.cn.yang.servlet;

import com.cn.yang.service.MainPageService;
import com.cn.yang.service.NewsService;
import com.cn.yang.service.ProductService;
import com.cn.yang.service.impl.MainPageServiceImpl;
import com.cn.yang.service.impl.NewsServiceImpl;
import com.cn.yang.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/main")
public class MainServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获得headLink的List。
        MainPageService headLink = new MainPageServiceImpl();
        req.setAttribute("headLink",headLink.selectHeadLink());
        //获得头尾 存储的字段，
        MainPageService headFootService = new MainPageServiceImpl();
        req.setAttribute("headFootService",headFootService.selectHeadFoot());
        //====================================================================================
        //主页面的内容： 模块名称
        MainPageService service = new MainPageServiceImpl();
        req.setAttribute("mainModel",service.findMainPage());
// 第一部分的<!-- 某某医疗设备设施-->的六张标题
        ProductService servlet = new ProductServiceImpl();
        req.setAttribute("productClassify",servlet.findClassify());
        // //新闻时间内容--取部分
        NewsService newsService = new NewsServiceImpl();
        req.setAttribute("newsService",newsService.findNews());

        req.getRequestDispatcher("/jsp/main.jsp").forward(req,resp);
    }
}
